package top.likeqc.leetcode.editor.cn;

/**
 * @see <a
 *     href="https://leetcode.cn/problems/check-if-number-is-a-sum-of-powers-of-three">leetcode题库</a>
 */
public class CheckIfNumberIsASumOfPowersOfThree {
    public static void main(String[] args) {
        Solution solution = new CheckIfNumberIsASumOfPowersOfThree().new Solution();
    }
    // leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public boolean checkPowersOfThree(int n) {
            // 转换为 3 进制
            while (n != 0) {
                if (n % 3 == 2) {
                    return false;
                }
                n /= 3;
            }
            return true;
        }
    }
    // leetcode submit region end(Prohibit modification and deletion)

}
